<?php

class Article extends BaseTopic implements iEditBody {
	
	public function prepare($new, $item, $inputs) {
		return $this->create_body("Artikel", $item, $inputs);
	}

	public function check_content($values) {
		$ok = $this->checker->check_tags_advanced($values['body'], "body");
		$ok = $ok && $this->checker->check_tag_closures($values['body']);
		return $ok && $this->checker->check_exists($values['body'], "body");
	}

	public function get_edit_body() {
		$sql = $this->db_access->db_query_select(array(array('*')), array("ARTICLE"), "item_id = {$this->id}");
		$sqlresult = $this->db_access->db_do_query($sql);
		$article = $this->db_access->db_fetch_array($sqlresult);
		return $article['body'];
	}

	protected function derive_info() {
		return substr($_POST['link'], 0, 50) . ((strlen($_POST['link']) > 50) ? "&hellip;" : "");
	}

	protected function get_sql_from_post($item_id) {
		return $this->db_access->db_query_insert(array('item_id', 'body'), 
				array($item_id, 
						$this->db_access->db_sqlize($_POST['body'])), 
				"ARTICLE");
	}
}

?>
